package cn.gztang.util;

import org.dozer.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author GaoFeng2017
 * @date 2018/8/1 15:03
 */

@Component
public class DozerUtil {
    
    @Autowired
    private Mapper mapper;
    
    public <T> List<T> mapList(List srcList,Class<T> clazz) {

        if (srcList == null) {
            return null;
        }

        List<T> destList = new ArrayList<>(srcList.size());
        
        for (Object obj : srcList) {
            destList.add(mapper.map(obj,clazz));
        }

        return destList;
    }
    
}
